<?php
/**
 * Created by Yury Patrin.
 * Time: 26.11.13 23:05
 */

class Profile extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->library('users');
    }

    public function activate($userId, $activationCode)
    {
        $result = $this->users->activateUser($userId, $activationCode);

        if ($result['code'] == Users::CODE_USER_ACTIVATE_ERROR)
            $this->load->view('profile/activate_error');
        elseif ($result['code'] == Users::CODE_USER_ACTIVATE_DONE)
            $this->load->view('profile/activate_done');
    }

    public function forgotPwd($code)
    {
        $userId = $this->users->getUserIdByForgotCode($code);

        if (!$userId)
            $this->load->view('profile/forgot-password-error');
        else
            $this->load->view('profile/forgot-password', ['flush_code' => $code]);
    }
}